package com.qilu.pe.support.util;

import android.graphics.Color;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.widget.TextView;

public class ViewUtil {

    // 修改必填项文字样式
    public static void setImportantText(TextView tv, String txt) {
        if (null == tv || TextUtils.isEmpty(txt)) {
            throw new IllegalArgumentException("控件或者文本数据不能为空!");
        }
        ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(Color.RED);
        SpannableString spannableString = new SpannableString(txt);
        spannableString.setSpan(foregroundColorSpan, 0, 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        tv.setText(spannableString);
    }
}
